

<?php
    $url = new Url();
    $arr_region = LoadConfig::$region;
?>

<script type="text/javascript">

    $(document).ready(function(){

        $("#<?php echo $page?>").removeClass('numbertrang');
        $("#<?php echo $page?>").addClass('numbertrang_1');

        $('#comment').keypress(function(e){
            if(e.keyCode == 13 && !e.shiftKey){
                $(this).trigger("enterKey");
            } 
        });

        $('#comment').bind("enterKey",function(e){
            comment();
        });
        
        setInterval(function(){
            loadComment();
        },5000);

    });

    loadBoxThongke();

    loadBoxKetQua();

    loadBoxTienIch();
    
    loadComment();

    function loadBoxKetQua(){
        var url = "<?=$url->createUrl('home/boxketqua');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#boxketqua").html(msg);
            }
        });
    }

    function loadBoxTienIch(){
        var url = "<?=$url->createUrl('home/boxtienich');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#boxtienich").html(msg);
            }
        });
    }

    function loadBoxThongke(){
        var url = "<?=$url->createUrl('home/boxthongke');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#boxthongke").html(msg);
            }
        });
    }
    
    function loadComment()
    {
        var url = "<?=$url->createUrl('user/comment');?>";
        var id_thread = "<?php echo $id;?>";
        var page = "<?php echo $page;?>";
        var alias = "<?php echo $alias;?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{
                id_thread: id_thread,
                page: page,
                alias: alias,
            },
            success: function(msg){
                $('#box_comment').html(msg);
            }
        });
    }

    function comment(){
        var url = "<?=$url->createUrl('user/comment');?>";
        var comment = $('#comment').val();
        var id_thread = "<?php echo $id;?>";
        var page = "<?php echo $page;?>";
        var alias = "<?php echo $alias;?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{
                comment: comment,
                id_thread: id_thread,
                page: page,
            },
            success: function(msg){
                if(msg == 1){
                    alert('Bạn phải đăng nhập để bình luận');
                }else{
                    $('#box_comment').html(msg);
                    $('#comment').val("");
                }
            }
        });
    }

</script>

<div class="leftMain">  
    <div class="titleCHAT">Chủ đề hot</div>
    <div class="SM">
        <div class="HOT">  
            <div class="img_HOT">
                <img width="100px" src="<?php echo $data['image_100']?>"/>
            </div>
            <div class="title_HOT">
                <?php echo $data['title'];?>
            </div>
            <div class="descrip_HOT">
                <?php echo $data['description'];?>
            </div>
            <div class="like_HOT">
                
                <div id="fb-root" style="float: right;"></div>
                    <script>(function(d, s, id) {
                        var js, fjs = d.getElementsByTagName(s)[0];
                        if (d.getElementById(id)) return;
                        js = d.createElement(s); js.id = id;
                        js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=670383849682676&version=v2.0";
                        fjs.parentNode.insertBefore(js, fjs);
                        }(document, 'script', 'facebook-jssdk'));
                    </script>
                    <div class="fb-like" data-href="http://10h.vn<?php echo Yii::app()->createUrl('user/detail',array('id'=>$data['id'],'alias'=>$data['alias'],'page'=>1));?>" data-layout="button" data-action="like" data-show-faces="false" data-share="true"></div>
                
                <a class="like_face">Comment(<?php echo count($all);?>)</a>
            </div>
            <div class="both"></div>
        </div>
        <div class="box_comment" id="box_comment">

        </div>

        <div class="searchSM">
            </br>
            </br>
            <input id="comment" class="boxsearchSM" type="text" maxlength="100" size="5" placeholder="Nhập nội dung thảo luận" name="a">
            <a class="buttonsearchSMS" onclick="comment();" href="javascript:void(0);">Send</a>
        </div>

    </div>
</div>
<div class="rightMain">
    <div class="Box" id="boxketqua"></div>

    <div class="Box" id="boxtienich"></div>

    <div class="Box" id="boxthongke"></div>
</div>
<div class="both"></div>
